<template>
	<div class="app">
		<h1>{{msg}},学生姓名是{{studentName}}</h1>
		<!-- 通过props方法实现子给父传值 -->
		<School :getSchoolName="getSchoolName"></School>
		
		<!-- 绑定一个自定义事件，实现子传父(第一种写法v-on) -->
		<Student v-on:zouyizhen="getStudentName"></Student>
		<!-- 绑定一个自定义事件，实现子传父(第二种写法ref) -->
		<!-- <Student ref="student" @demo="m1"></Student> -->
	</div>
</template>

<script>
	import Student from './components/Student'
	import School from "./components/School"
	export default{
		name:'App',
		components:{Student,School},
		data() {
			return {
				msg: '你好！！！',
				studentName:''
			}
		},
		methods:{
			getSchoolName(schoolName){
				console.log('app收到了信息',schoolName)
			},
			getStudentName(name){
				console.log('被调用了',name);
				this.studentName=name
			},
			m1(){
				console.log('demo事件被触发了');
			}
		},
		// mounted(){
		// 	this.$refs.student.$on('zouyizhen',this.getStudentName)
		// }
	}
</script>

<style scoped>
	.app{
		background-color: gray;
	}
</style>
